package com.kotlin.novel.base

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.OnLifecycleEvent
import com.kotlin.novel.R



abstract class BaseActivity : AppCompatActivity(), LifecycleOwner {

    private lateinit var loadingView: View

    @OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        loadingView = LayoutInflater.from(this).inflate(R.layout.loading_view, null)
        setContentView(getLayoutResId())
        initView()
        initData()
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
    override fun onDestroy() {
        super.onDestroy()
    }

    abstract fun getLayoutResId(): Int

    abstract fun initView()

    abstract fun initData()


}